package com.lavida.project.system.contractmana.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.lavida.project.system.contractmana.domain.Contractmana;

public interface ContractmanaMapper {
	//查询合同管理信息
	List<Contractmana> selectContractmana(Contractmana contractmana);
	
	void insertContract(Contractmana contractmana);
	
	
	//通过编号来删除
	void deleteContract(int id);
	
	
	Contractmana getContractmana(int id);
	
	void updateContract(Contractmana contractmana);
	
	/**
	 * 保单到期提醒,前60天
	 * @return
	 */
	@Select("SELECT id,insurance_name,end_date,ABS(DATEDIFF(CURDATE(),end_date)) AS days FROM contractmana WHERE contract_type='保单' AND contract_status!='合同已终止' AND DATEDIFF(CURDATE(),end_date)>=-59 AND DATEDIFF(CURDATE(),end_date)<1")
	List<Contractmana> selectPolicyExpirationContract();
	
	
	/**
	 * 合同签订补全提醒，合同签约日期有了，起始日或到期日为空
	 * @return
	 */
	@Select("SELECT * FROM contractmana WHERE contract_status='合同签订中' AND DATE IS NOT NULL AND (start_date IS NULL OR end_date IS NULL)")
	List<Contractmana> selectSignCompleteContract();
	
	
	/**
	 * 合同到期提醒,前60天
	 * @return
	 */
	@Select("SELECT id,insurance_name,end_date,ABS(DATEDIFF(CURDATE(),end_date)) AS days FROM contractmana WHERE contract_type!='保单' AND contract_status!='合同已终止' AND DATEDIFF(CURDATE(),end_date)>=-59 AND DATEDIFF(CURDATE(),end_date)<1")
	List<Contractmana> selectContractExpirationContract();
	
	/**
	 * 查询没有上传的合约
	 * @return
	 */
	@Select("SELECT * FROM contractmana WHERE annex IS NULL")
	List<Contractmana> selectNoUpload();
}
